{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" team="{:url('/admin/productcate')}" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">搜索名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="keyword" value="{$Request.get.keyword}" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" href="javascript:;" onclick="cate_add()">添加商品分类</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table" style="text-align:center">
                <thead>
                <tr>
                    <th>分类名称</th>
                    <th>分类图片</th>
                    <th>排序值</th>
                    <th>添加时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                    {volist name="list" id="vo"}
                        <tr>
                            <td>{$vo['title']}</td>
                            <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>                            
                            <td>{$vo['sort']}</td>                            
                            <td>{$vo['addtime']|date="Y-m-d H:i:s"}</td>
                            <td>
                                <a style="text-decoration:none" title="编辑" href="javascript:;" onclick="productcate_edit({$vo.id})" class="layui-btn layui-btn-radius layui-btn-default layui-btn-xs">编辑</a>
                                <a style="text-decoration:none" title="删除" onClick="del({$vo.id},'3')" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">删除</a>
                            </td>
                        </tr>
                    {/volist}
                
                        {if condition="empty($list)"}
                            <tr><td colspan='10' style="text-align:center;">暂时没有数据！</td></tr>
                        {/if}
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default" style="margin-left:40%">
               {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['table'], function(){

    });
    
    
    //添加商品分类
    function cate_add() {
        var url  = "{:url('/admin/productcate_add')}";
        layer.open({
            type: 2,
            title: '添加商品分类',
            shadeClose: false,
            shade: 0.3,
            area: ['50%', '80%'],
            content: url,
        });
    }
    
    // 编辑商品分类
    function productcate_edit(id) {
        var url  = "{:url('/admin/productcate_edit?id="+id+"')}";
        layer.open({
            type: 2,
            title: '编辑商品分类',
            shadeClose: false,
            shade: 0.3,
            area: ['60%', '80%'],
            content: url,
        });
    }
    
    //上下架
    function del(id,stu){
        layer.confirm('确认要执行当前操作吗？',function(){
            var url = "{:url('/admin/productcate_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'stu':stu},function(data){
                if(data.status == 1){
                    layer.msg(data.msg,{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1500},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }



</script>
</body>
</html>


